<?php
/**
 * @fileoverview    专辑内容页面
 * @author          xinhua
 * @date            Feb  02 11:31:49 CST 2012
 * @copyright       sina meila
 */
include_once ('../../__global.php');
class collectionContent extends ml_controller{

    private $_uid;
    private $_page=1;                                    //默认第0页
    private $_begin=0;
    private $col_id;
    private $total;
    private $finnal=array();
    private $Acontent=array();
    private $uids=array();                              //用来获取nick


    public function initParam()    {

        $this->col_id = intval($this->input('col_id','G'));//获取专辑id
        $this->_uid = intval($this->input('uid','G'));//获取被查看人的uid
            
        $tmp=$this->input('page','G');
        $this->_page = empty($tmp)?$this->_page:$tmp;//页
        $this->_begin =($this->_page-1)*120;
    }

    public function checkParam() {
        if (empty($this->col_id)){//不传id跳到404
            $this->redirect(ML_PAGE_404);
        }
        
        if(empty($this->_uid))
        {
            $this->_uid = $this->__visitor['uid'];
        }
        $this->init_owner($this->_uid);
    }


    public function main(){


        $model=new ml_model_dbCollectionRe();
        $ridAndComment=$model->getListByCid($this->_uid, $this->col_id);
        $this->total=$model->getTotalByCid($this->_uid, $this->col_id);

        $modelCol=new ml_model_dbCollectionBox();
        $descrip=$modelCol->getDescrip($this->_uid, $this->col_id);

        foreach ($ridAndComment as &$value) {
            $rids[]=$value['rid'];//资源id数组
            $value['col_name']=$descrip['name'];
        }

        $contentModel=new ml_model_dbContent();
        $contentData=$contentModel->get_content_by_rids($rids);

        $htmlModel=new ml_biz_pinboard($contentData, $this->_uid, $this->__isself,true,$ridAndComment);
        $contentData=$htmlModel->output();

        $data=array();//分列
        $contentData=empty($contentData)?array():$contentData;
        foreach ($contentData as $k => $v) {
            switch ($k%3) {
                case 0: $data['col1'][] = $v;    break;
                case 1: $data['col2'][] = $v;    break;
                case 2: $data['col3'][] = $v;    break;
            }

        }


        $last=$this->total['num']-($this->_page-1)*120<=ML_FEED_PAGESIZE?true:false;
        $this->set_scope_var('$col_id', $this->col_id);
        $this->set_scope_var('$totalPage', floor($this->total['num']/120)+1);//总页数
        $this->set_scope_var('$currentPage', intval($this->_page));//当前页
        $this->set_scope_var('$segment', 1);
        $this->set_scope_var('$lastSegment', $last);


        $obizUser = ml_biz_user_getinfo::get_instance();
        $obizUser->initUser($this->_uid,$this->__visitor['uid']);
        $userData=$obizUser->getUserArea();



        $Amore=$modelCol->getMoreCol($this->_uid,$this->col_id);

        $oIFollow = new ml_biz_module_iFollow();
        $this->finnal['iFollow'] = $oIFollow->getList($this->_uid);
        $this->finnal['content']=$data;
        $this->finnal['description']=Tool_string::un_html($descrip['description']);
        $this->finnal['name']=Tool_string::un_html($descrip['name']);
        $this->finnal['cnt_col']=$descrip['cnt_col'];
        $this->finnal['col_id'] = $this->col_id;
        $this->finnal['more']=ml_tool_collectionOutput::parseColTpl($Amore);
        $this->finnal['title']=$this->finnal['name']."宝贝集-美啦";
        $this->finnal['owner_uid']=$this->_uid;
        $this->finnal=array_merge($this->finnal,$userData);
            
        $this->page_output('user::collectionContent', $this->finnal);

    }


}
new collectionContent();
?>